﻿namespace Sai.Test.TestDataBuilders
{
	using System;
	using System.Collections.Generic;
	using System.Linq;
	using System.Text;
	using Sai.Core.Introspection;

	public class FieldDeclarationBuilder
	{
		private string fieldName;
		private bool isObsolete;
		private TypeName declaringType = new TypeName(new FullyQualifiedName("System.Object"));
		private TypeName fieldType;
		
		public static FieldDeclarationBuilder Field()
		{
			return new FieldDeclarationBuilder();
		}

		public FieldDeclarationBuilder Named(string name)
		{
			this.fieldName = name;

			return this;
		}

		public FieldDeclarationBuilder OfType(string name)
		{
			this.fieldType = new TypeName(new FullyQualifiedName(name));
			
			return this;
		}

		public FieldDeclarationBuilder OfType(TypeName type)
		{
			this.fieldType = type;
			
			return this;
		}

		public FieldDeclarationBuilder InClass(string name)
		{
			this.declaringType = new TypeName(new FullyQualifiedName(name));
			return this;
		}

		public FieldDeclarationBuilder InClass(TypeName type)
		{
			this.declaringType = type;

			return this;
		}

		public FieldDeclarationBuilder IsObsolete()
		{
			this.isObsolete = true;
			
			return this;
		}

		public FieldDeclaration Build()
		{
			return new FieldDeclaration(this.fieldName,
								this.fieldType,
								new ObsoleteMarker(this.isObsolete),
								this.declaringType);
		}

	}
}
